<template>
  <div class="lbsPosition">
    <iframe v-if="LBSInfo.addTime" :src="'/googleMap.html?lat='+LBSInfo.lat+'&lng='+LBSInfo.lon" style="width: 100%;height: 600px;" frameborder="0"></iframe>
    <p v-else>no data</p>
  </div>
</template>

<script>
  import mixin from '@/service/mixin';
  import Pagination from '@/components/pagination';

  export default {
    name: 'contact',
    components: {
      Pagination
    },
    props: {
      userId: {
        default: ''
      },
      orderId: {
        default: ''
      }
    },
    mixins: [mixin],
    data() {
      return {
        LBSInfo: {
          addTime: '',
          lat: '',
          lon: ''
        }
      };
    },
    methods: {
      getLbs() {
        const params = {
          userId: this.userId
        };
        this.$api.customer.getLbs(params).then((res) => {
          const { status, data, error } = res;
          if ('1' === status && '00000000' === error && data) {
            data.forEach((item) => {
              if (this.LBSInfo.addTime < item.addTime) {
                this.LBSInfo.addTime = item.addTime;
                this.LBSInfo.lat = item.lat;
                this.LBSInfo.lon = item.lon;
              }
            });
          }
        });
      }
    },
    created() {
      this.getLbs();
    }
  };
</script>

<style lang="scss" scope>
  //
</style>
